home *** CD-ROM | disk | FTP | other *** search
- class prop.pz2 extends MovieClip
- {
- var rq;
- var cq;
- var rStart;
- var rAgl;
- var c1Img;
- var c2Img;
- var c3Img;
- var usedTimes;
- var usedTimesMax;
- var clockwise;
- var answerR;
- var answerC;
- var aBtnNum;
- function pz2()
- {
- super();
- this.rq = this.cq = 3;
- this.rStart = new Array();
- this.rAgl = new Array();
- this.c1Img = new Array();
- this.c2Img = new Array();
- this.c3Img = new Array();
- this.usedTimes = 0;
- this.usedTimesMax = 2;
- this.resetMe();
- }
- function resetMe()
- {
- this.init();
- this.clockwise = Math.random() * 1 <= 0.5 ? false : true;
- this.answerR = Math.floor(Math.random() * 3);
- this.answerC = Math.floor(Math.random() * 3);
- var _loc7_ = false;
- var _loc2_ = 0;
- while(_loc2_ < this.rq)
- {
- this.rStart[_loc2_] = Math.floor(Math.random() * 4);
- this.rAgl[_loc2_] = this.normalDeg(45 * Math.floor(Math.random() * 8));
- this.c1Img[_loc2_] = Math.ceil(Math.random() * 3);
- this.c2Img[_loc2_] = Math.ceil(Math.random() * 3);
- this.c3Img[_loc2_] = Math.ceil(Math.random() * 3);
- if(this.answerR != _loc2_ && !_loc7_)
- {
- _loc7_ = true;
- var _loc6_ = Math.floor(this.cq * Math.random());
- this["r" + _loc2_ + "c" + _loc6_].gotoAndStop("mask");
- }
- var _loc3_ = 0;
- while(_loc3_ < this.cq)
- {
- var _loc4_ = (_loc3_ + this.rStart[_loc2_]) % 4;
- this["r" + _loc2_ + "c" + _loc3_]["ctt3_" + _loc4_]._visible = true;
- this["r" + _loc2_ + "c" + _loc3_]["ctt3_" + _loc4_].gotoAndStop(this.c3Img[_loc2_]);
- this["r" + _loc2_ + "c" + _loc3_].ctt1.gotoAndStop(this.c1Img[_loc2_]);
- this["r" + _loc2_ + "c" + _loc3_].ctt2.gotoAndStop(this.c2Img[_loc2_]);
- switch(_loc3_)
- {
- case 0:
- this["r" + _loc2_ + "c" + _loc3_].ctt1._rotation = this.rAgl[_loc2_];
- break;
- case 1:
- this["r" + _loc2_ + "c" + _loc3_].ctt1._rotation = this.normalDeg(this.rAgl[_loc2_] + 180);
- break;
- case 2:
- var _loc5_ = !this.clockwise ? -1 : 1;
- this["r" + _loc2_ + "c" + _loc3_].ctt1._rotation = this.normalDeg(this.rAgl[_loc2_] + 180 + _loc5_ * 45);
- }
- _loc3_ = _loc3_ + 1;
- }
- _loc2_ = _loc2_ + 1;
- }
- this["r" + this.answerR + "c" + this.answerC].gotoAndStop("tar");
- this.setBtns();
- }
- function setBtns()
- {
- this.aBtnNum = Math.floor(Math.random() * 4);
- var _loc4_ = this.rAgl[this.answerR];
- var rAgl;
- switch(this.answerC)
- {
- case 0:
- rAgl = _loc4_;
- break;
- case 1:
- rAgl = this.normalDeg(_loc4_ + 180);
- break;
- case 2:
- var _loc5_ = !this.clockwise ? -1 : 1;
- rAgl = this.normalDeg(_loc4_ + 180 + _loc5_ * 45);
- }
- var _loc2_ = 0;
- while(_loc2_ < 4)
- {
- if(_loc2_ == this.aBtnNum)
- {
- this["btn" + _loc2_].onPress = this.btnPrsR;
- this["btn" + _loc2_].ctt1._rotation = rAgl;
- this["btn" + _loc2_].ctt1.gotoAndStop(this.c1Img[this.answerR]);
- this["btn" + _loc2_].ctt2.gotoAndStop(this.c2Img[this.answerR]);
- var _loc3_ = 0;
- while(_loc3_ < 4)
- {
- this["btn" + _loc2_]["ctt3_" + (this.answerC + this.rStart[this.answerR]) % 4]._visible = true;
- this["btn" + _loc2_]["ctt3_" + _loc3_].gotoAndStop(this.c3Img[this.answerR]);
- _loc3_ = _loc3_ + 1;
- }
- }
- else
- {
- this["btn" + _loc2_].onPress = this.btnPrsW;
- this["btn" + _loc2_].ctt1._rotation = this.normalDeg(rAgl + 45 + 45 * _loc2_);
- this["btn" + _loc2_].ctt1.gotoAndStop(this.c1Img[this.answerR]);
- this["btn" + _loc2_].ctt2.gotoAndStop(this.c2Img[this.answerR]);
- _loc3_ = 0;
- while(_loc3_ < 4)
- {
- this["btn" + _loc2_]["ctt3_" + (this.answerC + this.rStart[this.answerR] + _loc2_) % 4]._visible = true;
- this["btn" + _loc2_]["ctt3_" + _loc3_].gotoAndStop(this.c3Img[this.answerR]);
- _loc3_ = _loc3_ + 1;
- }
- }
- _loc2_ = _loc2_ + 1;
- }
- }
- function init()
- {
- var _loc4_ = 0;
- while(_loc4_ < this.rq)
- {
- var _loc3_ = 0;
- while(_loc3_ < this.cq)
- {
- this["r" + _loc4_ + "c" + _loc3_].gotoAndStop("normal");
- this["r" + _loc4_ + "c" + _loc3_]._alpha = 100;
- var _loc2_ = 0;
- while(_loc2_ < 4)
- {
- this["r" + _loc4_ + "c" + _loc3_]["ctt3_" + _loc2_]._visible = false;
- _loc2_ = _loc2_ + 1;
- }
- _loc3_ = _loc3_ + 1;
- }
- _loc4_ = _loc4_ + 1;
- }
- _loc4_ = 0;
- while(_loc4_ < 4)
- {
- _loc3_ = 0;
- while(_loc3_ < 4)
- {
- this["btn" + _loc4_]["ctt3_" + _loc3_]._visible = false;
- _loc3_ = _loc3_ + 1;
- }
- _loc4_ = _loc4_ + 1;
- }
- }
- function normalDeg(r)
- {
- if(r >= 180)
- {
- r -= 360;
- }
- if(r <= -180)
- {
- r += 360;
- }
- return r;
- }
- function btnPrsW()
- {
- this._parent.prsWrong();
- }
- function btnPrsR()
- {
- this._parent.prsRight();
- }
- function prsWrong()
- {
- this.usedTimes = this.usedTimes + 1;
- if(this.usedTimes > 2)
- {
- _global.scene.arkShape.gotoAndStop("broken");
- this._visible = false;
- }
- _global.ctn.sndCtrl.playSound("snd_pzWrong");
- this._visible = false;
- }
- function prsRight()
- {
- _global.scene.arkShape.gotoAndPlay("win");
- _global.ctn.sndCtrl.playSound("snd_pzRight");
- if(!_global.scene.pzArkScoreOver)
- {
- _global.scene.pzArkScoreOver = true;
- _global.ctn.game.addScore(300,500,137,60);
- _global.ctn.game.addScore(124,Math.round(412 * (1 - this.usedTimes / this.usedTimesMax)),137,65);
- }
- this.unloadMovie();
- }
- }
-